package handlers

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"no/models"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	num := c.PostForm("num")
	ck := models.Ck{
		Name: name,
		Num:  num,
	}
	models.DB.Create(&ck)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "添加成功",
		"data": ck,
	})
	return
}

func List(c *gin.Context) {
	var ck []models.Ck
	models.DB.Find(&ck)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "展示成功",
		"data": ck,
	})
	return
}
